<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Enumerate all code points with their Unicode general categories</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="intlchar.enumcharnames.html">« IntlChar::enumCharNames</a></li>
      <li style="float: right;"><a href="intlchar.foldcase.html">IntlChar::foldCase »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.intlchar.html">IntlChar</a></li>
    <li>Enumerate all code points with their Unicode general categories</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="intlchar.enumchartypes" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlChar::enumCharTypes</h1>
  <p class="verinfo">(PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">IntlChar::enumCharTypes</span> &mdash; <span class="dc-title">Enumerate all code points with their Unicode general categories</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intlchar.enumchartypes-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>IntlChar::enumCharTypes</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   Enumerates efficiently all code points with their Unicode general categories. This is useful for building data
   structures, for enumerating all assigned code points, etc.
  </p>
  <p class="para">
   For each contiguous range of code points with a given general category (&quot;character type&quot;), the
   <code class="parameter">callback</code> function is called. Adjacent ranges have different types. The Unicode Standard
   guarantees that the numeric value of the type is 0..31.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intlchar.enumchartypes-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">callback</code></dt>

    <dd>

     <p class="para">
      The function that is to be called for each contiguous range of code points with the same general category.
      The following three arguments will be passed into it:
      <ul class="simplelist">
       <li class="member"><span class="type">int</span> <code class="literal">$start</code> - The starting code point of the range</li>
       <li class="member"><span class="type">int</span> <code class="literal">$end</code> - The ending code point of the range</li>
       <li class="member"><span class="type">int</span> <code class="literal">$name</code> - The category type (one of the <code class="literal">IntlChar::CHAR_CATEGORY_*</code> constants)</li>
      </ul>
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intlchar.enumchartypes-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-intlchar.enumchartypes-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2499">
   <p><strong>示例 #1 Enumerating over a sample range of code points</strong></p>
   <div class="example-contents">
    <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />IntlChar</span><span style="color: #007700">::</span><span style="color: #0000BB">enumCharTypes</span><span style="color: #007700">(function(</span><span style="color: #0000BB">$start</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$end</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"U+%04x&nbsp;through&nbsp;U+%04x&nbsp;are&nbsp;in&nbsp;category&nbsp;%d\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$start</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$end</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #007700">);<br />});<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
    <div class="cdata"><pre>
U+0000 through U+0020 are in category 15
U+0020 through U+0021 are in category 12
U+0021 through U+0024 are in category 23
U+0024 through U+0025 are in category 25
U+0025 through U+0028 are in category 23
U+0028 through U+0029 are in category 20
U+0029 through U+002a are in category 21
U+002a through U+002b are in category 23
U+002b through U+002c are in category 24
U+002c through U+002d are in category 23
U+002d through U+002e are in category 19
U+002e through U+0030 are in category 23
U+0030 through U+003a are in category 9
...
</pre></div>
   </div>
  </div>
 </div>


</div></div></div></body></html>